home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / satellit / vstsrc / vstsqnt.c < prev    next >
C/C++ Source or Header  |  1995-01-23  |  7KB  |  153 lines

  1. /*
  2.  * %W% %E% %U%  [EXTREL_1.2]
  3.  *
  4.  * VersaTrack orbit calculations are based on those that appear in Dr. Manfred
  5.  * Bester's sattrack program (the Unix(tm) versions 1 and 2).
  6.  *
  7.  * The data from which the maps where generated come from "xsat", an
  8.  * X-Windows program by David A. Curry (N9MSW).
  9.  *
  10.  * Site coordinates come from various sources, including a couple of
  11.  * World Almanacs, and also from both of the programs mentioned above.
  12.  *
  13.  * The following are authors' applicable copyright notices:
  14.  *
  15.  *                                                                               
  16.  * Copyright (c) 1992, 1993, 1994 Manfred Bester. All Rights Reserved.        
  17.  *                                                                           
  18.  * Permission to use, copy, modify, and distribute this software and its      
  19.  * documentation for educational, research and non-profit purposes, without   
  20.  * fee, and without a written agreement is hereby granted, provided that the  
  21.  * above copyright notice and the following three paragraphs appear in all    
  22.  * copies.                                                                    
  23.  *                                                                              
  24.  * Permission to incorporate this software into commercial products may be    
  25.  * obtained from the author, Dr. Manfred Bester, 1636 M. L. King Jr. Way,     
  26.  * Berkeley, CA 94709, USA.                                                   
  27.  *                                                                             
  28.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,  
  29.  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF    
  30.  * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED   
  31.  * OF THE POSSIBILITY OF SUCH DAMAGE.                                         
  32.  *                                                                             
  33.  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT       
  34.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A    
  35.  * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"       
  36.  * BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,  
  37.  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.                                   
  38.  *                                                                             
  39.  *                                                                             
  40.  * Copyright 1992 by David A. Curry                                            
  41.  *                                                                             
  42.  * Permission to use, copy, modify, distribute, and sell this software and its 
  43.  * documentation for any purpose is hereby granted without fee, provided that  
  44.  * the above copyright notice appear in all copies and that both that copyright
  45.  * notice and this permission notice appear in supporting documentation.  The  
  46.  * author makes no representations about the suitability of this software for  
  47.  * any purpose.  It is provided "as is" without express or implied warranty.   
  48.  *                                                                             
  49.  * David A. Curry, N9MSW                                                       
  50.  * Purdue University                                                           
  51.  * Engineering Computer Network                                                
  52.  * 1285 Electrical Engineering Building                                        
  53.  * West Lafayette, IN 47907                                                    
  54.  * davy@ecn.purdue.edu                                                         
  55.  *                                                                             
  56.  * VersaTrack Copyright (c) 1993, 1994 Siamack Navabpour. All Rights Reserved.
  57.  *
  58.  * Permission is hereby granted to copy, modify and distribute VersaTrack
  59.  * in whole, or in part, for educational, non-profit and non-commercial use
  60.  * only, free of charge or obligation, and without agreement, provided that
  61.  * all copyrights and restrictions noted herein are observed and followed, and
  62.  * additionally, that this and all other copyright notices listed herein
  63.  * appear unaltered in all copies and in all derived work.
  64.  *
  65.  * This notice shall not in any way void or supersede any of the other authors
  66.  * rights or privileges.
  67.  *
  68.  * VersaTrack IS PRESENTED FREE AND "AS IS", WITHOUT ANY WARRANTY OR SUPPORT.
  69.  * YOU USE IT AT YOUR OWN RISK. The author(s) shall not be liable for any
  70.  * direct, indirect, incidental, or consequential damage, loss of profits or
  71.  * other tangible or intangible losses or benefits, arising out of or related
  72.  * to its use. VersaTrack carries no warranty, explicit or implied, including
  73.  * but not limited to those of merchantablity and fitness for a particular
  74.  * purpose.
  75.  *
  76.  * Siamack Navabpour, 12342 Hunter's Chase Dr. Apt. 2114, Austin, TX 78729.
  77.  * sia@bga.com or sia@realtime.com.
  78.  */
  79.  
  80.  
  81. #include <windows.h>
  82. #include <math.h>
  83.  
  84. #include "vstdefs.h"
  85. #include "constant.h"
  86. #include "vsttype.h"
  87. #include "vstextrn.h"
  88.  
  89.  
  90. void
  91. SquintAngle(sp, trueAnomaly, curRaan, curArgPerigee, radius)
  92. select_t *sp;
  93. double trueAnomaly, curRaan, curArgPerigee, radius;
  94. {
  95.     mode_t *mp;
  96.     track_t *tp;
  97.     site_t *sitep;
  98.     double phi, cosPhi, sinPhi, xOrb, yOrb, zOrb, xObs, yObs, zObs, scalar;
  99.     double sinArgPerigee, cosArgPerigee, sinInclination, cosInclination;
  100.     double satSqX, satSqY, satSqZ;
  101.     double xObsOrb, yObsOrb, zObsOrb;
  102.     extern double absol(double, double, double);
  103.     
  104.     tp = sp->sl_tp;
  105.     
  106.     if (!(tp->satp->s_flags & SF_ATTITUDE))
  107.         return;
  108.         
  109.     sitep = tp->sitep;
  110.     mp = tp->satp->s_modep;
  111.     
  112.     sinArgPerigee = sin(curArgPerigee);
  113.     cosArgPerigee = cos(curArgPerigee);
  114.     sinInclination = sin(tp->inclination);
  115.     cosInclination = cos(tp->inclination);
  116.         
  117.     xOrb    =  radius * cos(trueAnomaly);   /* position in orbital plane */
  118.     yOrb    =  radius * sin(trueAnomaly);
  119.     zOrb    =  ZERO;
  120.  
  121.     phi     = reduce(tp->lastime - curRaan - HALFPI, ZERO, TWOPI);
  122.     cosPhi  = cos(phi);
  123.     sinPhi  = sin(phi);
  124.  
  125.     xObs    = sitep->c_vecX;
  126.     yObs    = sitep->c_vecY;
  127.     zObs    = sitep->c_vecZ;
  128.  
  129.     xObsOrb = (-sinArgPerigee * cosInclination*cosPhi + 
  130.                 cosArgPerigee * sinPhi) * xObs + 
  131.                 ( sinArgPerigee * cosInclination*sinPhi + 
  132.                 cosArgPerigee * cosPhi) * yObs -
  133.                 sinArgPerigee * sinInclination * zObs;
  134.  
  135.     yObsOrb = (-cosArgPerigee * cosInclination*cosPhi - 
  136.                 sinArgPerigee * sinPhi) * xObs + 
  137.                 ( cosArgPerigee * cosInclination*sinPhi - 
  138.                 sinArgPerigee * cosPhi) * yObs - 
  139.                 cosArgPerigee * sinInclination * zObs;
  140.  
  141.     zObsOrb =  -sinInclination * cosPhi * xObs +sinInclination * sinPhi * yObs +
  142.                 cosInclination * zObs;
  143.  
  144.     satSqX = -xOrb - xObsOrb;
  145.     satSqY = -yOrb - yObsOrb;
  146.     satSqZ = -zOrb - zObsOrb;
  147.         
  148.     scalar = mp->attVecX*satSqX + mp->attVecY*satSqY + mp->attVecZ*satSqZ;
  149.  
  150.     sp->sl_rp->r_squint = (float) (acos (- scalar /
  151.             absol(satSqX, satSqY, satSqZ)) * CRD );
  152. }
  153.